var app = require('../app'),
    formMod = require('../../modules/form'),
    ajaxOff = false; 

formMod.listen("/mediateagency/addAndEdit",{
    validError:function(validResutl){
        ajaxOff = false;
        var item  = validResutl.element;
        if(item.attr('name')=='agency[agency_name]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写机构名称');
            }
        }
        if(item.attr('name')=='agency[card_code]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写社会信用代码');
            }
        }
        if(item.attr('name')=='agency[mobile]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写联系方式');
            }
        }
        if(item.attr('name')=='agency[address]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写联系地址');
            }
        }
         
    },
    //操作中清除提示
    cleanup:function(item){
        $('.error-tips').hide().html("");
    },
    success: function(result){
        var res = result.data;
        if(res.code == 200){
            toastr.success('提交成功');
            window.location.href="https://mediate.gzclearing.com/mediateagency/index";
        }else{
            toastr.error(res.message);
        }

    },
    error: function(){}
});